<?php
class Register extends MY_Controller {
	function index(){
		$this->load->model('M_course');
		$data['additional_css'] = array(
			array(
			  'href' => 'assets/css/jquery-ui-1.9.2.custom.min.css',
			  'rel' => 'stylesheet',
			  'type' => 'text/css',
			  'media' => 'screen'
			)
		);
		$data['footer_scripts'] = array('jquery-ui-1.9.2.custom.min.js');
			
			
		
		
		$data['title'] = 'Register';
		$data['school_data'] = $this->school_data;
		
		$data['db_entries'] = $this->M_course->get_all_levels();
		
		
		$this->template->set_body('page-blocks/page-module/vStudentRegister', $data, FALSE);
		$this->template->load_template('default', $data);
	}
	
	function register_student(){
		/*
		if($this->form_validation->run('add_student_register') == FALSE){
			$session = array('type' => 'error', 'msg' => 'Please fill up all the required (*) fields correctly');
			$this->session->set_flashdata($session);
		}
		else {
			echo 22;
			$this->load->model('M_student');
			$v = (object) $this->input->post();
			
			if($this->M_student->add_student($v)){
				$session = array('type' => 'success', 'msg' => 'You have successfully registered to the system<br/> Click <a href="">Here</a> to login to your account');
				$this->session->set_flashdata($session);
				
			}
			
		}
		*/
		$this->load->model('M_student');
			$v = (object) $this->input->post();
			
			if($this->M_student->add_student($v)){
				$session = array('type' => 'success', 'msg' => 'You have successfully registered to the system<br/> Click <a href="'.site_url('home').'">Here</a> to login to your account');
				$this->session->set_flashdata($session);
				
			}
		redirect('register');
	}
}
?>